from flask import Blueprint

# 创建API蓝图
api_bp = Blueprint('api', __name__)

# 导入并注册各个API模块
from . import user_api
from . import article_api
from . import banner_api
from . import assessment_api
from .admin_api import admin_bp
from .upload_api import upload_bp

# 注册admin_bp
api_bp.register_blueprint(admin_bp, url_prefix='/admin')

# 注册upload_bp
api_bp.register_blueprint(upload_bp, url_prefix='/admin')

# 可以在这里添加通用的API错误处理
@api_bp.errorhandler(404)
def not_found(error):
    return {'error': 'Not found'}, 404

@api_bp.errorhandler(400)
def bad_request(error):
    return {'error': 'Bad request'}, 400

@api_bp.errorhandler(500)
def internal_server_error(error):
    return {'error': 'Internal server error'}, 500